<?php
require_once(dirname(__FILE__).'/../config.php');
$tz = trim($_REQUEST['tz']);		
if(!empty($tz)){
	$back_act = urldecode($tz);
}else{
    $back_act='';
}
?>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>微信扫码登录</title>
<meta name="format-detection" content="telephone=no">  
<meta name="apple-mobile-web-app-capable" content="yes">  
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport">
<link rel="stylesheet" type="text/css" href="/oauth/wechat/css/wxlogin.css">
<script src="/oauth/wechat/js/jquery.js"></script>
<style type="text/css">
#output{width:280px;margin:0 auto;border:1px solid #E2E2E2;}
#output canvas{padding:20px;display:block;}
.wx_login_text p{line-height:24px;}
.wxsq_title{padding-top:20px;}
</style>
</head>
<body bgcolor="#fff"> 
<section classid="wxlogin">
<div class="wxsq_title">微信登录</div>
<div class="wx_login_ewm"><div id="output"></div></div>
<div class="wx_login_text">
<p class="wx_login_p" style="margin-top:10px;">请使用微信扫描二维码登录</p>
<p class="wx_login_p" style="line-height:18px;">“<?php echo $cfg_webname;?>”</p>
</div>
</section>
<?php
$time = time();
?>
<input type="hidden" id="url" value="<?php echo $cfg_basehost;?>/oauth/wechat/wxsq.php?etime=<?php echo $time;?>&tzde=<?php echo $back_act;?>" />
<input type="hidden" id="time" value="<?php echo $time;?>" />
<input type="hidden" id="tzde" value="<?php echo $back_act;?>" />
<script type="text/javascript" src="/oauth/wechat/js/jquery.qrcode.min.js"></script>
<script>var domain = '<?php echo $cfg_basehost; ?>';</script>
<script src="/oauth/wechat/js/wxlogin.js"></script>
<script>
//写入二维码请求
var time = $("#time").val();
$.post("/oauth/wechat/ajax.php",{enews:"wxlogin",time:time},function(data){
	if (data=='dberror') {
		$(".wx_login_p").text("").text("请求失败，请重新尝试!");
	}
	else{
        jQuery(function(){
	      var url=$("#url").val();
          jQuery('#output').qrcode({
                render    : "canvas",//二维码生成
                width   : 240,
                height  : 240,
                foreground: "#555",
                background: "#FFF",
                text    : ""+url+""
          }); 
        })
        setInterval("login()", 3000);
	}   
})
</script>
</body>
</html>